package com.bangyu.monitor.modular.system.biz;

import com.bangyu.monitor.core.common.constant.ConstantEnum;
import com.bangyu.monitor.core.common.page.LayuiPageFactory;
import com.bangyu.monitor.core.shiro.ShiroKit;
import com.bangyu.monitor.modular.system.entity.Bridge;
import com.bangyu.monitor.modular.system.entity.Risk;
import com.bangyu.monitor.modular.system.service.BridgeService;
import com.bangyu.monitor.modular.system.service.RiskService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.Transformer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Auther: zhangxue
 * @Date: 19/5/3 10:17
 * @Description:
 */
@Component
public class RiskBiz {

    @Autowired
    private RiskService riskService;

    @Autowired
    private BridgeBiz bridgeBiz;




    public Page<Risk> pageByPermission(String condition,Integer riskLevel,Integer riskType){
        List<Bridge> bridges = bridgeBiz.listByPermission(condition);
        if(CollectionUtils.isEmpty(bridges)) return LayuiPageFactory.defaultPage();
        List<Long> bridgeIds = Lists.newArrayList();
        for(Bridge bridge:bridges){
            bridgeIds.add(bridge.getBridgeId());
        }
        if(CollectionUtils.isEmpty(bridgeIds)){
            return LayuiPageFactory.defaultPage();
        }
        return riskService.pageQueryByBridges(bridgeIds,riskLevel,riskType);
    }
}
